import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router) //让vue使用Router


const router = [
    {
        path: "/login",
        component: ()=> import("../views/login.vue")
    },
    {
        path: "/layout",
        component: ()=> import("../views/layout.vue"),
        children: [
            {
                path: "/",
                redirect: "/index"
            },
            {
                path: "/index",
                name: "index",
                components: {
                    default: ()=> import("../views/Index.vue"),
                    oth: ()=>import("../views/Food.vue")
                }
            },
            {
                path: "/food",
                component: ()=> import("../views/Food.vue")
            },
            {
                path: "/cookie",
                component: ()=> import("../views/Cookie.vue")
            },
            {
                path: "/f_detail/:detail",
                component: ()=> import("../views/food_detail.vue")
            },
        ]
    },
    {
        path: "*",
        component: ()=> import("../views/Page_404.vue")
    }
] //路由的规则

export default new Router({
    routes: router,
    linkActiveClass: "active"
}) //导出路由对象，对象已经加载规则